package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.model.enums.ReleaseStatus;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author 86188
 * @version v1.0
 * @project ShangTingApartment
 * @Date 2025/7/14 8:09
 * @company []
 * @description
 */
@Component
public class StringToItemTypeConverter implements Converter<String, ReleaseStatus> {
    @Override
    public ReleaseStatus convert(String source) {
        ReleaseStatus[] values = ReleaseStatus.values();
        for (ReleaseStatus value : values) {
            if (value.getCode()==Integer.parseInt(source)){
                return value;
            }
        }
        throw new RuntimeException("非法参数异常，仅支持：0 , 1;");
    }


}
